<script>
import KTableHeader from "./KTableHeader"

let tableIdSeed = 1

export default {
  name: "KTable",
  props: ['data'],
  components: {KTableHeader},
  created() {
    this.tableId = "el-table_" + tableIdSeed++
  },
  data() {
    return {columns: []}
  },
  render: function (h) {
    let columns = this.columns
    console.log('columns', columns)
    return h('table', [
      h('div', this.$slots.default),
      h('thead', [
            // h(KTableHeader),
            h(KTableHeader, {
              props: {
                columns: this.columns,
                data: this.data
              }
            }),
            // h('div', KTableHeader),
            // h('tr', columns.map(e => h('th', e.label))),
          ]
      ),
      h('tbody', this.data.map((row, rindex) => {
            return h('tr', columns.map(column => {
              return h('td', column.renderCell(h, {row, rindex}))
            }))
          })
      ),
    ])
  }
}
</script>
